const MyPromise = require('./4-mypromise.js');
// const MyPromise = Promise;

const promise1 = new MyPromise(function(resolve, reject) {
    // resolve('resolve 1');
    reject('reject 1');
});
const promise2 = new MyPromise(function(resolve, reject) {
    // setTimeout(() => {
    //     resolve(' resolve 2');
    // }, 2000);
    reject(' reject 2');
});
// promise1.finally(function () {
//     console.log('finally');
//     return new MyPromise((resolve, reject) => {
//         setTimeout(() => {
//             resolve('111')
//         }, 2000);
//     });
// }).then(value => {
//     console.log('value1', value);
    
// }, reason => {
//     console.log('reason1', reason);
// }).then(value => {
//     console.log('value2', value);
// }, reason => {
//     console.log('reason1', reason);
// });


// MyPromise.allSettled([1,promise2, promise1]).then(value => {
//     console.log('value -all ', value);
// });

MyPromise.any([promise1, promise2]).then(value => {
    console.log('value -any ', value);
}, err => {
    console.log('err -any ', err);
});


// MyPromise.reject(promise1).then(res => {
//     console.log('value', value);
// }, err => {
//     console.log('err', err);
// })


